<?php

apf_require_controller('Oa_Attendance_Abstract');

class Oa_Attendance_AjaxController extends Oa_Attendance_AbstractController {

    public function handle_request() {
        $params = $this->request->get_parameters();

        if($params['do']=='get_depart'){
            if(empty($params['city'])){
                echo json_encode(0);exit;
            }
            apf_require_class('Bll_Attendance_Department');
            $depart_bll = new Bll_Attendance_Department();
            $depart_list = $depart_bll->get_all_department();

            $cityarr=explode(',',$params['city']);
            $res = array();
            foreach($depart_list as $city=> $val){
                if(in_array($city,$cityarr)){
                    foreach($val as $value){
                        $res[]=$value;
                    }
                }
            }
            echo json_encode($res);exit;
        }
    }
}